from config import ASDF_PACKAGES
from util import run, ensure_root, file_exists, log, file_backup, file_delete

def plugin_install(name, plugin_url):
    run(f'asdf plugin-add {name} {plugin_url}')

def install(name, version, extras):
    for extra in extras:
        run(extra)
    run(f'asdf install {name} {version}')

def global_set(name, version):
    run(f'asdf global {name} {version}')

def main():
    for name, params in ASDF_PACKAGES.items():
        version, plugin_url, extras = params
        plugin_install(name, plugin_url)
        install(name, version, extras)
        global_set(name, version)

if __name__ == "__main__":
    main()
